package com.ruoyi.wxorali.utils;

import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;

public class QiniuTokenGenerator {
   static  String accessKey = "BsC1eHmirhG1dAqQhSpETQVCr4Yv9dZxE9tJw7F1";
   static String secretKey = "s1_fYX_DRg4if6kFKNuFS5GblX_UKQSnjWCvaXKI";
    /*public static void main(String[] args) {
        // 七牛云的 Access Key 和 Secret Key


        // 七牛云存储空间的名称
        String bucketName = "your-bucket-name";

        // 生成上传凭证
        String uploadToken = generateUploadToken(accessKey, secretKey, bucketName);

        System.out.println("上传凭证：" + uploadToken);
    }*/

    public static String generateUploadToken( String bucketName) {
        Auth auth = Auth.create(accessKey, secretKey);
        return auth.uploadToken(bucketName);
    }

   /* public static void main(String[] args) {
        // 七牛云的 Access Key 和 Secret Key
        String accessKey = "your-access-key";
        String secretKey = "your-secret-key";

        // 要审核的图片 URL
        String imageUrl = "http://your-image-url";

        // 生成图片审核凭证
        String token = generateImageAuditToken(accessKey, secretKey, imageUrl);

        System.out.println("图片审核凭证：" + token);
    }*/

    private static String generateImageAuditToken(String accessKey, String secretKey, String imageUrl) {
        Auth auth = Auth.create(accessKey, secretKey);
        StringMap map = new StringMap();
        map.put("url",imageUrl);
        return auth.uploadToken("your-bucket-name", null, 3600, map);
    }
}
